home *** CD-ROM | disk | FTP | other *** search
- Path: mother.usf.edu!boheme!millert
- From: millert@boheme.csee.usf.edu (Timothy Miller)
- Newsgroups: comp.lang.c++
- Subject: copy vs. assignment
- Date: 1 Mar 1996 22:56:01 GMT
- Organization: University of South Florida
- Message-ID: <4h7va1$1ev@mother.usf.edu>
- NNTP-Posting-Host: 131.247.1.95
- X-Newsreader: TIN [version 1.2 PL2]
-
- Well, it seems that overloading the = operator for assigning one instance
- of a class to one of its own kind is futile, because no matter what, it
- uses the copy constructor to copy the class.
-
- My problem is that I need to do one thing if an object is initialized by
- one of its own kind, like this;
-
- Matrix p;
- // stuff done to p;
- Matrix q = p; // <- right here
-
- And I need to do something else if an already existing object is being
- assigned to like this:
-
- Matrix p, q;
- // stuff done to p
- q = p; // <- this should call a different class member
-
- No matter what I do, it seems that q gets initialized by the
- constructor, regardless of whether or not it's already been created, even
- if I overload the = operator.
-
- --
- ---------------------------------------------------------------------------
- Timothy Miller, millert@grad.csee.usf.edu Theoretical Linguistics
- http://www.csee.usf.edu/~millert Music Theory, Computer Engineering
- ---------------------------------------------------------------------------
- Cunning linguists are very skilled with their tongues.
-